var express = require('express');
var path = require('path');
var fs = require('fs');
var app = express();
var router = express.Router();



app.engine('art', require('express-art-template'));
app.set('view engine', 'art')
app.set('view options', {
    debug: true,
    imports: {
      ctx:""
    }
});

app.set('views', path.resolve(__dirname, '../dist/views'))
app.use("/public",express.static('dist/public'));


router.get('/', function(req, res){
    fs.readFile('./app/data/toolset.json','utf-8',function(err,data){
        if (err) {
            throw err;  
        }
        res.render("index",{
            widget:JSON.parse(data)
        })
    })
});
router.get('/admin', function(req, res){
    res.render("admin/index")
});
router.get('/admin/header', function(req, res){
    res.render("admin/header")
});
router.get('/admin/content', function(req, res){
    res.render("admin/content")
});
router.get('/admin/page', function(req, res){
    res.render("admin/page")
});


app.use('/',router);
require('./api/v1')(app)

var server = app.listen(34,function(){
    console.log('running in port 34')
});